package com.yuhanginfo.modules.web.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yuhanginfo.common.service.WebCrudService;
import com.yuhanginfo.modules.web.dao.WebReturnsGoodsDao;
import com.yuhanginfo.modules.web.entity.WebReturnsGoods;

/**
 * 
 * 
 * @author yinhao
 * @version 2017-10-13
 */
@Service
@Transactional(readOnly = true)
public class WebExchangeHistoryService extends WebCrudService<WebReturnsGoodsDao, WebReturnsGoods> {
	
	@Autowired
	private WebReturnsGoodsDao webReturnsGoodsDao;


	public List<WebReturnsGoods> findAll(WebReturnsGoods returnsGoods) {
		return webReturnsGoodsDao.findListByUser(returnsGoods);
	}

	public Map<String, Object> findDetail(WebReturnsGoods returnsGoods){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		WebReturnsGoods returnsGoodsResult = webReturnsGoodsDao.getByCode(returnsGoods);
		resultMap.put("returnsGoods", returnsGoodsResult);
		if("1".equals(returnsGoodsResult.getOrdersType())){
			resultMap.put("detailCount", webReturnsGoodsDao.findReturnGoodsDetail(returnsGoods));
		}else if("2".equals(returnsGoodsResult.getOrdersType())){
			resultMap.put("detailCount", webReturnsGoodsDao.findReturnGoodsDetailCombo(returnsGoods));
		}else{
			resultMap.put("resultCode", "0");
			resultMap.put("resultMessage", "order_type错误");
		}
		
		return resultMap;
	}
}